Skip to content

fix(tcp): open the receive window when the read buffer is smaller than the MTU - #5

Merged
acking-you merged 1 commit into
devfrom
fix/receive-window-small-buffer
Oct 27, 2026
Merged

acking-you merged 1 commit into
devfrom
fix/receive-window-small-buffer

Conversation

@acking-you

Copy link
Copy Markdown
Owner

Addresses the P2 review finding on #4 (src/stream/tcp.rs): silly-window avoidance advertised a zero window until a full MTU of receive space was free. With an MTU above TcpConfig::read_buffer_size (e.g. 32768 against the default 16384) that can never happen, so even the SYN-ACK of an empty connection carried a zero window and data never flowed. The rule came from upstream (narrowlink#95/narrowlink#99 window work).

The threshold is now min(MTU, read_buffer_size / 2), the bound RFC 1122 §4.2.3.3 gives, computed by Tcb::get_recv_window_threshold, and the comparison uses the unclamped free space. With the default MTU 1500 and 16 KiB buffer the threshold — and the behaviour — are unchanged.

Test

mtu_above_the_read_buffer_still_opens_the_receive_window opens a stream with an MTU of twice the read buffer and asserts the SYN-ACK window is non-zero; it fails on the old rule ("an empty read buffer advertised a zero window") and passes now. The open helper gained an MTU-taking variant for it.

Verified (nightly-2026-10-26)

fmt --check, clippy --all-targets --all-features -D warnings, test --all-features (43 unit + 23 doc).

🤖 Generated with Claude Code

…n the MTU

Silly-window avoidance advertised a zero window until a full MTU of space was
free. With an MTU above TcpConfig::read_buffer_size (e.g. 32768 against the
default 16384) that never happens, so even the SYN-ACK of an empty connection
carried a zero window and normal data never flowed. Bound the threshold by
half the read buffer, as RFC 1122 4.2.3.3 does; with the default MTU 1500 and
16 KiB buffer the threshold, and the behaviour, are unchanged.

Raised in review of #4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T12:55:37.765764Z 68a956a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@acking-you
acking-you merged commit e4ef686 into dev Oct 27, 2026
4 checks passed
@acking-you
acking-you deleted the fix/receive-window-small-buffer branch October 27, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant